package com.woniuxy.house.web;

import com.woniuxy.house.service.ConcernService;
import com.woniuxy.house.vo.PostConcernVo;
import com.woniuxy.house.vo.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/concern")
public class ConcernController {
    @Autowired
    private ConcernService concernService;
    @RequestMapping("/addPostConcern")
    public ResponseEntity addPostConcern(@RequestBody PostConcernVo postConcernVo){
        concernService.addPostConcern(postConcernVo.getUserId(), postConcernVo.getPostId());

        return ResponseEntity.SUCCESS;
    }

    @RequestMapping("/getPostConcernByUserId")
    public ResponseEntity getPostConcernByUserId(Integer userId){
        return new ResponseEntity("200","ok",concernService.getPostConcernByUserId(userId));
    }


    @RequestMapping("/deletePostConcernByUserIdAndPostId")
    public ResponseEntity deletePostConcernByUserIdAndPostId(@RequestBody PostConcernVo postConcernVo){
        concernService.deletePostConcernByUserIdAndPostId(postConcernVo.getUserId(), postConcernVo.getPostId());
        return ResponseEntity.SUCCESS;
    }
}
